package com.nbjtjc.safe.mapper.edu;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.model.edu.EduRequirementSurveyItem;
import com.nbjtjc.safe.model.edu.EduRequirementUserSurveyResults;
import com.nbjtjc.util.MyMapper;
@Mapper
public interface EduRequirementUserSurveyResultsMapper extends MyMapper<EduRequirementUserSurveyResults> {
//    @Select("select * from edu_requirement_user_survey_results where req_invest_id=#{reqInvestId} and user_id=#{userId}")
//    List<EduRequirementUserSurveyResults> findByReqInvestIdAndUserId(@Param("reqInvestId") int reqInvestId,@Param("userId") int userId);
//    
    List<EduRequirementUserSurveyResults> search(@Param("erusr") EduRequirementUserSurveyResults EduRequirementUserSurveyResults);
    List<EduRequirementUserSurveyResults> searchDetail(@Param("erusr") EduRequirementUserSurveyResults EduRequirementUserSurveyResults);

    List<EduRequirementUserSurveyResults> searchDone(@Param("erusr") EduRequirementUserSurveyResults EduRequirementUserSurveyResults);

    List<EduRequirementUserSurveyResults> searchDoneDetail(@Param("erusr") EduRequirementUserSurveyResults EduRequirementUserSurveyResults);

    @Insert("INSERT INTO edu_requirement_user_survey_results (`req_invest_id`,`user_id`,`department`,`status`) "
    		+ "(SELECT r.req_invest_id AS req_invest_id,u.user_id AS `user_id`,d.name AS `department`,0 AS `status` FROM sys_user u LEFT JOIN sys_dept d ON u.dept_id = d.id  RIGHT JOIN edu_requirement_respondent r ON u.`user_id` = r.`user_id` WHERE r.req_invest_id = #{reqInvestId})")
    int createUserResult(@Param("reqInvestId") int reqInvestId);
    
    List<EduRequirementUserSurveyResults>  showItemRes(@Param("item") EduRequirementSurveyItem item);
    
//    List<EduRequirementUserSurveyResults>  showItemRes2(@Param("item") EduRequirementSurveyItem item);

  List<EduRequirementUserSurveyResults> findUserByReqId(@Param("reqInvestId") int reqInvestId);
  
  List<EduRequirementUserSurveyResults> findUndoUserByReqId(@Param("reqInvestId") int reqInvestId,@Param("status") int status);

  
//    @Select("select * from edu_requirement_user_survey_results where req_invest_id = #{reqInvestId}")
//    List<EduRequirementUserSurveyResults> findAllByReqInvestId(@Param("reqInvestId") int reqInvestId);
}